<?php

include("config.php");  
$page_num = $_GET["page_num"];
$prev_num="";
$next_num="";
$max_num="";

$max_num = get_news_MaxPage($conn);
if($page_num<1 || $page_num>$max_num) $page_num=1;
$prev_num=$page_num-1;
if($page_num == $max_num) {$next_num =0;} else {$next_num=$page_num+1;}


$startnum = ($page_num-1)*10;
$sql = "SELECT * FROM `news` ORDER BY `news`.`publicTime` DESC LIMIT $startnum , 10";
$rs = &$conn->Execute($sql);
$news_Detail_List = $rs->getArray();
	 

$tpl->assign("news_Detail_List",$news_Detail_List);
$tpl->assign("prev_num",$prev_num);
$tpl->assign("next_num",$next_num);
$tpl->assign("page_num",$page_num);
$tpl->assign("max_num",$max_num);

$tpl->display('news_list.html');


function get_news_MaxPage($conn)
{
	$sql ="select COUNT(*) from news";
	$rs = &$conn->Execute($sql);
	$data = $rs->getArray();
	$count = $data[0][0];
	
	return( ceil($count/10));
	

}

?>